<?php

class Core_Model_Global_Area extends Dcmp_Model_Spoor {

    public function __construct() {
        parent::__construct();
    }

    public function getPageCategories(){
        return App::getModel('design/collection_page_category')->filterByAreaId($this->getId());
    }

    public function getPageTemplates(){
        return App::getModel('design/collection_page_template')->filterByAreaId($this->getId());
    }

    public function getModules(){
        return App::getModel('global/collection_module')
                ->joinArea()
                ->filterByAreaId($this->getId());
    }

//    public function getRoles() {
//        return App::getModel('global/collection_role')
//                ->queryFilter('domain_id', $this->getId())
//                ->querySort('parent_id')
//                ->load();
//    }
//
//    public function getaccreditComponents() {
//        return App::getModel('global/collection_resource_uri')
//                ->queryFilter('domain_id', $this->getId())
//                ->load();
//    }

//    public function validate() {
//        if ($this->isNew()) {
//            if ($this->getTable()->checkExists(array('code' => $this->getCode()))) {
//                return array($this->__f('global.message.repeated', '{global.label.domain}', $this->getCode()));
//            }
//        }
//        return TRUE;
//    }

    protected function initializeTable($table) {
        $table->setName('{t}global_area');
        $table->createColumn('id', 'guid', TRUE);
        $table->createColumn('name', 'string');
        $table->createColumn('url', 'string');
        $table->createColumn('namespace', 'string');
        $table->createColumn('is_backend', 'integer');
        $table->createColumn('code')->setUpdateable(FALSE);
        parent::initializeTable($table);
    }

}